<template>
<el-container>
    <div class="">
        <MinisterMenu></MinisterMenu>
    </div>
    <el-main style="padding:0px">
        <el-row>
            <el-col :span="3">
                <h2>查看驳回表</h2>
            </el-col>
        </el-row>

        <el-table :data="rejectList" style="width: 100%" :row-class-name="tableRowClassName">
          <el-table-column type="index"></el-table-column>
            <el-table-column label="项目名称" width="180">
                <template #default="scope">
                    <div style="display: flex; align-items: center">
                        <span style="margin-left: 10px">{{ scope.row.project.name }}</span>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="项目详情" width="180">
                <template #default="scope">
                  <span style="margin-left: 10px">{{ scope.row.project.details}}</span>
                </template>
            </el-table-column>
          <el-table-column label="驳回原因" width="180">
            <template #default="scope">
              <span style="margin-left: 10px">{{ scope.row.reason}}</span>
            </template>
          </el-table-column>
          <el-table-column label="驳回时间" width="180">
            <template #default="scope">
              <span style="margin-left: 10px">{{ scope.row.rejectTime}}</span>
            </template>
          </el-table-column>
          <el-table-column label="项目开始时间" width="180">
            <template #default="scope">
              <span style="margin-left: 10px">{{ scope.row.project.startTime}}</span>
            </template>
          </el-table-column>
          <el-table-column label="项目预计结束时间" width="180">
            <template #default="scope">
              <span style="margin-left: 10px">{{ scope.row.project.estTime}}</span>
            </template>
          </el-table-column>

<!--            <el-table-column label="操作">-->
<!--                <template #default="scope">-->
<!--                  <el-popconfirm-->
<!--                      confirm-button-text="Yes"-->
<!--                      cancel-button-text="No"-->
<!--                      icon-color="red"-->
<!--                      title="确定要重新提交吗?"-->
<!--                      @click="submit(scope.$index, scope.row)"-->
<!--                  >-->
<!--                    <template #reference>-->
<!--                      <el-button size="small">重新提交</el-button>-->
<!--                    </template>-->
<!--                  </el-popconfirm>-->
<!--&lt;!&ndash;                    <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">Delete</el-button>&ndash;&gt;-->
<!--                </template>-->
<!--            </el-table-column>-->
        </el-table>

    </el-main>

</el-container>
</template>

<script>
import MinisterMenu from '@/components/menu/MinisterMenu.vue'
import instanceToken from "@/utlis/tokenIdentify";
export default {
    name: 'StateView',
    components: {
        MinisterMenu,
    },
    data() {
        return {
            rejectList:[],
        };
    },
    methods: {
        initData() {
            instanceToken.get("/project/minister/rejectProjectCheck").then(res => {
                console.log(res.data.data)
              this.rejectList = res.data.data;
            })
        },
      tableRowClassName({row, rowIndex}){
        var date = new Date();
        let today = date.toLocaleDateString();
        var startDates = today.split("/");
        var endDates = row.project.estTime.split("-");
        var startDate = new Date(startDates[0], startDates[1]-1 , startDates[2]);
        var endDate = new Date(endDates[0], endDates[1]-1, endDates[2]);
        var days = (parseInt((endDate - startDate) / 1000 / 60 / 60 / 24));//把相差的毫秒数转换为天数
        console.log(days)
        if(days<=7){
          return 'warning-row';
        }
      },
      submit(index,row){
          instanceToken.get("")      }

    },
    created() {
        this.initData();
    },
    computed: {},
    watch: {},
}
</script>

<style  scoped>
.el-table .warning-row {
  background-color: red;
}
</style>
